//
//  FRPCollectionViewCell.m
//  FunctionalReactivePixels
//
//  Created by Ran on 15/9/6.
//  Copyright (c) 2015年 gintong. All rights reserved.
//

#import "FRPCollectionViewCell.h"
#import <ReactiveCocoa/ReactiveCocoa.h>

@interface FRPCollectionViewCell()


@property(nonatomic, weak)IBOutlet UIImageView *imageView;
//@property(nonatomic, strong)RACDisposable *subscription;

@end

@implementation FRPCollectionViewCell

- (void)awakeFromNib {
    // Initialization code
    
    self.backgroundColor = [UIColor darkGrayColor];
    
    RAC(self.imageView, image) = [[RACObserve(self, photoModel.imageData) ignore:nil] map:^id(id value) {
        return [UIImage imageWithData:value];
    }];
}

//- (void)setPhotoModel:(FRPPhotoModel *)model
//{
//    self.subscription = [[[RACObserve(model, imageData) filter:^BOOL(id value) {
//        return value != nil;
//    }] map:^id(id value) {
//        return [UIImage imageWithData:value];
//    }] setKeyPath:@keypath(self.imageView, image) onObject:self.imageView];
// 
//}
//
//- (void)prepareForReuse{
//    
//    [super prepareForReuse];
//    [self.subscription dispose], self.subscription = nil;
//    
//}

@end
